package pzl.kt.study.base

import org.junit.Test

//集合
class Collection {

    @Test
    fun test数组() {
        //【1】
        //public inline constructor(size: Int, init: (Int) -> T)
        //[init] function. The [init] function returns an array element given its index.
        var arr1 = Array<String>(5, { x -> "value:" + x.toString() })
        for (s in arr1) {
            println(s)
        }

        //【2】
        var arr2 = arrayOf(1, 2, 3, 4, 5, 6)
        for (s in arr2) {
            println(s)
        }

        println("arr1.count() = " + arr1.count())
        println("arr1.size = " + arr1.size)
        println("arr1.first() = " + arr1.first())
        println("arr1.component1() = " + arr1.component1())
        println("arr1.component2() = " + arr1.component2())
        println("arr1.component3() = " + arr1.component3())
        println("arr1.component4() = " + arr1.component4())
        println("arr1.component5() = " + arr1.component5())
        println("arr1.last() = " + arr1.last())
        println(arr1.contains("value:1"))

        var arr3 = arrayOf(1, 2, 3, 4, 5, 6, 7)
        println(arr3.drop(2))
        arr3 = arrayOf(1, 2, 3, 4, 5, 6, 7)
        println(arr3.dropLast(2))
        arr3 = arrayOf(1, 2, 3, 4, 5, 6, 7)
        //arr3.dropWhile { it <= 3 }
        //for (s in arr3) {
        //     print("${s}  ")
        //}
    }

}